<#include
        "../../common/com.html"  /> <@layout>
<head>
    <!-- page specific plugin styles -->
    <link rel="stylesheet" href="${ctx}/static/assets/css/ui.jqgrid.css" />
    <!-- ace styles -->
    <link rel="stylesheet" href="${ctx}/static/assets/css/ace.min.css" />
    <script src="${ctx}/static/inc/platform/js/ajax.js"></script>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/cbb/artDialog/skins/blue.css">
    <script src="${ctx}/static/cbb/artDialog/jquery.artDialog.js"></script>
</head>
<script>
    function cleankhid(){
        parent.parent.closeDialog();

    }


    /**
     * 删除选中的模型信息
     */
    function dels(obj){
        url = '${ctx}/cgglWp/deletewp/';
        $("#id").attr("value",obj);
        $('#myform').form('submit', {
            url : url,
            onSubmit : function() {
            },
            success : function(data) {
                // 回填页面
                alert(data);
                window.location.reload();
            }
        });
    }
</script>
<body>

<div class="page-content">

    <div class="row-fluid">
        <div class="span12">
            <form class="form-inline" id="myform">
                <input type="hidden" name="id" id="id">
                物品名称：<input type="text"  name="search_LIKE_wpmc" id="search_LIKE_wpmc"   class="query "  style="min-height: 24px;width: 140px"      />
                &nbsp; &nbsp;
                <a href="#"  id="search_btn"  onclick="queryModel() " class="btn btn-info btn-small" > 查询 </a>
                <a href="#"  class="btn btn-danger btn-small bigger-110"   onclick="cleankhid();">取消 </a>

            </form>
            <!-- PAGE CONTENT BEGINS -->
            <table id="grid-table"></table>
            <div id="grid-pager"></div>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.span -->
    </div><!-- /.row-fluid -->
</div><!-- /.page-content -->
<!-- page specific plugin scripts -->


<script src="${ctx}/static/assets/js/jqGrid/jquery.jqGrid.min.js"></script>
<script src="${ctx}/static/assets/js/jqGrid/i18n/grid.locale-cn.js"></script>
<script src="${ctx}/static/assets/js/markdown/markdown.min.js"></script>
<script src="${ctx}/static/assets/js/markdown/bootstrap-markdown.min.js"></script>

<script>
    var mcs ='${(mc)!}' ;
    var dms ='${(dm)!}'
    var dws ='${(dw)!}'
    function getReturnValue(mc,dm,dw){
//        if(window.ActiveXObject){ //IE
//            var mcs = window.dialogArguments.MC;
//            var dms = window.dialogArguments.DM;
//            window.returnValue = {
//                id : dm,
//                name :  mc
//            } ;
//            window.close();
//        }else{ //非IE
//            if(window.opener != undefined) {
//                window.opener.returnValue = "opener returnValue";
//            }
//            window.top.close();
//
//        }
        //for chrome

        if (mcs !="") {
            parent.parent.document.getElementById(mcs).value =mc;

        }
        if(dms !=""){
            parent.parent.document.getElementById(dms).value =dm;

        }
        if(dws !=""){
            parent.parent.document.getElementById(dws).value =dw;

        }
        parent.parent.closeDialog();
    }

</script>
<script type="text/javascript">


    $("#search_btn").click(function(){

        var search_LIKE_wpmc=$("#search_LIKE_wpmc").val();

        $("#grid-table").jqGrid('setGridParam',{
            url:'${ctx}/cgglWp/query',
            datatype:'json',
            postData:{  'search_LIKE_wpmc':search_LIKE_wpmc,'search_EQ_lbid':'${lbid}'}, //发送数据
            page:1
        }).trigger("reloadGrid"); //重新载入
    });


    jQuery(function($) {
        // 获取编号

        //  jqgrid
        var grid_selector = "#grid-table";
        var pager_selector = "#grid-pager";
        var search_LIKE_wpmc=$("#search_LIKE_wpmc").val();


//    var orgid=$("#orgid").val();

        jQuery(grid_selector).jqGrid({
            datatype: "json", //将这里改为使用JSON数据
            mtype:"POST",
            postData:{  'search_LIKE_wpmc':search_LIKE_wpmc}, //发送数据
            url:'${ctx}/cgglWp/query?search_EQ_lbid=${lbid}',
            height: '200px',
            footerrow:false,  //合计数据
            colNames:[ '物品名称','物品编号','物品单位','标记','',''],
            colModel:[
                {name:'wpmc', width:150,sortable:false},
                {name:'wpbh', width:150,sortable:false},
//          {name:'lrdates',index:'',width:50,sortable:false},
                {name:'wpdw',index:'',width:50,sortable:false} ,
                {name:'yxbz', width:80,sortable:false,formatter:'select', editoptions:{value:"0:无效;1:有效;"}},
                {name:'id', hidden:true},
                {name:'yxbz', hidden:true}
            ],
            rownumbers:true,//添加左侧行号
            sortname: 'id',
            sortable: false,
            viewrecords: true, //是否显示行数
            rowNum:30,
            rowList:[10,20,30],
            loadtext: '正在加载数据...',
            loadui : 'block',
            pager : pager_selector,
            altRows: true,
            shrinkToFit: true,


            loadComplete : function() {
                var table = this;
                setTimeout(function(){
//                styleCheckbox(table);
//                updateActionIcons(table);
                            updatePagerIcons(table);
//                enableTooltips(table);
                        },
                        0);
            } ,
            ondblClickRow: openview,
            autowidth: true

        });

        //按钮
        function printthis(cellvalue,options,rowObject){
            var ids=rowObject.id;
            var buttomHtml= "<a class='green' href=\"javascript:edits('" + ids + "')\" title='修改'><i class='icon-pencil bigger-130'></i></a> &nbsp;&nbsp;" +
                    "<a class='red' href=\"javascript:dels('" + ids + "')\" title='删除'><i class='icon-trash  bigger-130'></i></a> </div> ";

//        var buttomHtml="<a href='#' class='btn btn-primary btn-mini ' onclick='opennew()'><i class='icon-print  bigger-125  '>打印</i>  </a>";
            return buttomHtml
        }

        function  openview(rowid,iRow,iCol,e){
            var rowData = $("#grid-table").getRowData(rowid);
            getReturnValue(rowData.wpmc,rowData.id,rowData.wpdw);
        }


    });

    function updatePagerIcons(table) {
        var replacement =
        {
            'ui-icon-seek-first' : 'icon-double-angle-left bigger-150',
            'ui-icon-seek-prev' : 'icon-angle-left bigger-150',
            'ui-icon-seek-next' : 'icon-angle-right bigger-150',
            'ui-icon-seek-end' : 'icon-double-angle-right bigger-150'
        };
        $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){
            var icon = $(this);
            var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

            if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
        })
    }

    window.onresize = function  _doResize() {
        var ss = pageSize();
        $("#grid-table").jqGrid('setGridWidth', ss.WinW-10).jqGrid('setGridHeight', ss.WinH-200);
    }

    function pageSize() {
        var winW, winH;
        if(window.innerHeight) {// all except IE
            winW = window.innerWidth;
            winH = window.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) {// IE 6 Strict Mode
            winW = document.documentElement.clientWidth;
            winH = document.documentElement.clientHeight;
        } else if (document.body) { // other
            winW = document.body.clientWidth;
            winH = document.body.clientHeight;
        }  // for small pages with total size less then the viewport
        return {WinW:winW, WinH:winH};
    }

    //select2查询列表每次只查数据的前20条



</script>

</body>


</@layout>
